#!/bin/sh

# Purpose           : Shell script corrects the incorrect word passed as an argument from the word disctionary database
# Date/Time         : Tue Mar 20 11:29:42 IST 2012
# Modification Date :

# Validates the word
sanitize(){
	echo $1|sed 's/./\n&/g'|sort
}

DB="/usr/share/dict/words"

for w in $*; do
	for m in $(egrep "^["$w"]{"${#w}"}$" $DB); do
		[[ `sanitize $w` = `sanitize $m` ]] && (echo $m;break)
	done
done

